{% extends "common-content.html" %}

{% block title_ruler %}{% endblock %}

{% block title_row %}
    {% set tab = 'moss' %}
    {% set title = contest.name %}
    {% include "contest/contest-tabs.html" %}
{% endblock %}

{% block content_media %}
    <style>
        .panes {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
        }
        .pane {
            padding: 20px;
        }
    </style>
{% endblock %}

{% block content_js_media %}
    <script type="text/javascript">
        $(function () {
            $('.contest-moss').click(function () {
                return confirm({{ _('Are you sure you want to MOSS the contest?')|htmltojs }});
            });
            $('.contest-moss-delete').click(function () {
                return confirm({{ _('Are you sure you want to delete the MOSS results?')|htmltojs }});
            });
        });
    </script>
{% endblock %}
{% block body %}
    {% if has_results %}
        <table class="table striped">
            <thead>
            <tr>
                <th class="header">{{ _('Problem') }}</th>
                {% for lang in languages %}
                    <th class="header">{{ lang }}</th>
                {% endfor %}
            </tr>
            </thead>
            <tbody>
                {% for problem, results in moss_results %}
                    <tr id="problem-{{ problem.code }}">
                        <td>
                            <a href="{{ url('problem_detail', problem.code) }}">{{ problem.name }}</a>
                        </td>
                        {% for result in results %}
                            <td>
                                {% if result.submission_count %}
                                    <a href="{{ result.url }}">{% trans trimmed count=result.submission_count %}
                                        {{ count }} submission
                                    {% pluralize %}
                                        {{ count }} submissions
                                    {% endtrans %}</a>
                                {% else %}
                                    {{ _('No submissions') }}
                                {% endif %}
                            </td>
                        {% endfor %}
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
    <div class="panes">
        <div class="pane">
            <form method="post" action="{{ url('contest_moss', contest.key) }}">
                {% csrf_token %}
                <input type="submit" class="unselectable button full contest-moss" style="padding: 10px;"
                       value="{% if has_results %} {{ _('Re-MOSS contest') }} {% else %} {{ _('MOSS contest') }} {% endif %}">
            </form>
        </div>
        {% if has_results %}
            <div class="pane">
                <form method="post" action="{{ url('contest_moss_delete', contest.key) }}">
                    {% csrf_token %}
                    <input type="submit" class="unselectable button full contest-moss-delete" style="padding: 10px;"
                           value="{{ _('Delete MOSS results') }}">
                </form>
            </div>
        {% endif %}
    </div>
{% endblock %}
